'''
Created on 06/ago/2010

@author: rbutti
'''
from google.appengine.dist import use_library
use_library('django', '1.0')
from google.appengine.api import urlfetch
from google.appengine.api import memcache
from django.utils import simplejson as json

print "Content-Type: text/plain"
print ""
print "Hello, world!"

url = "https://graph.facebook.com/io.uso.ubuntu/feed"
try:
  result = urlfetch.fetch(url)
  if result.status_code == 200:
    arrayResult = json.loads(result.content)
    #print repr(arrayResult)
    
    for r in arrayResult['data']:
      #print r.picture
      #print r['picture']
      print r.get('name', 'NO').encode('utf-8', 'ignore')
      print r.get('picture', 'NO')
  else:
    print "No Content"

except:
  print "Error"

print repr(memcache)
#memcache.put("chave", "valore")
